#include "pipe_elements.h"
#include <deque>
#include <iostream>
using namespace std;
iQelement::iQelement(bits i,int adr, int clock)
{
    instruction=i;
    addr=adr;
    cycle=clock;
}
void iQueue::push_back(bits i, int adr, int clock)
{
    iQelement *temp=new iQelement(i,adr,clock);
    IQ.push_back(*temp);

}
void iQueue::push_front(iQelement temp)
{
    //iQelement *temp=new iQelement(i,adr,clock);
    IQ.push_front(temp);
}
void iQueue::fprint()
{
    cout<<"IQ:"<<endl;
    deque <iQelement>::iterator i;
            for(i=IQ.begin();i!=IQ.end();++i)
            {
                cout<<"[";
                (*i).instruction.fprint();
                 cout<<"]"<<endl;
            }
}
iQelement iQueue::next(int curcycle)
{
    if(!IQ.empty())
    {
    iQelement ret=IQ.front();
    if(ret.cycle!=curcycle)
    {
        IQ.pop_front();
        return ret;
    }
    else
        return *(new iQelement);
    }
    return *(new iQelement);
}
void iQueue::flush()
{
    IQ.clear();

}